#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
#define LC x<<1
#define RC x<<1|1
vector<ll> tree1[2000020],tree2[2000020];
ll n,m,q,res,ans=0;
bl ck[500050];
struct node{
	ll xl,xr,yl,yr;
}p[500050];
il bl cmp(node x,node y){
	return x.xr<y.xr;
}
void mdf(ll x,ll l,ll r,ll ql,ll qr,ll v){
	tree1[x].push_back(v);
	if(ql<=l&&r<=qr){
		tree2[x].push_back(v);
		return;
	}
	ll mid=(l+r)>>1;
	if(ql<=mid) mdf(LC,l,mid,ql,qr,v);
	if(mid<qr) mdf(RC,mid+1,r,ql,qr,v);
}
void query(ll x,ll l,ll r,ll ql,ll qr,ll lim){
	while(!tree2[x].empty()&&ck[tree2[x].back()]) tree2[x].pop_back();
	if(!tree2[x].empty()&&p[tree2[x].back()].xr>=lim) res=tree2[x].back();
	if(res) return;
	if(ql<=l&&r<=qr){
		while(!tree1[x].empty()&&ck[tree1[x].back()]) tree1[x].pop_back();
		if(!tree1[x].empty()&&p[tree1[x].back()].xr>=lim) res=tree1[x].back();
		return;
	}
	ll mid=(l+r)>>1;
	if(ql<=mid) query(LC,l,mid,ql,qr,lim);
	if(!res&&mid<qr) query(RC,mid+1,r,ql,qr,lim);
}
int main(){
	freopen("grid.in","r",stdin);
	freopen("grid.out","w",stdout);
	n=read();
	m=read();
	q=read();
	fr(i,1,q){
		p[i].xl=p[i].xr=read();
		p[i].yl=p[i].yr=read();
	}
	sort(p+1,p+q+1,cmp);
	fr(i,1,q){
		while(1){
			res=0;
			query(1,1,m,max(1ll,p[i].yl-2),min(m,p[i].yr+2),p[i].xl);
			if(!res) query(1,1,m,max(1ll,p[i].yl-1),min(m,p[i].yr+1),p[i].xl-1);
			if(!res) query(1,1,m,max(1ll,p[i].yl),min(m,p[i].yr),p[i].xl-2);
			if(!res) break;
			ck[res]=1;
			p[i].xl=min(p[i].xl,p[res].xl);
			p[i].xr=max(p[i].xr,p[res].xr);
			p[i].yl=min(p[i].yl,p[res].yl);
			p[i].yr=max(p[i].yr,p[res].yr);
		}
		mdf(1,1,m,p[i].yl,p[i].yr,i);
	}
	fr(i,1,q){
		if(ck[i]) continue;
		ans+=(p[i].xr-p[i].xl+1)*(p[i].yr-p[i].yl+1);
	}
	write(ans);
}
